{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "73bd968b-d970-4a05-94ef-4e7abf990827",
   "metadata": {},
   "source": [
    "Chapter 02\n",
    "\n",
    "# 除法\n",
    "Book_3《数学要素》 | 鸢尾花书：从加减乘除到机器学习 (第二版)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "00f9f3f6-3235-4b03-9510-fd68c8bdbd0a",
   "metadata": {},
   "source": [
    "该代码计算两个数字之间的除法并输出结果。代码首先定义了两个数，$6$和$3$，分别赋值给`num1`和`num2`，然后计算除法结果，即$6 \\div 3$，并将结果存储在`division`变量中。 \n",
    "\n",
    "### 代码细节\n",
    "\n",
    "1. **除法计算**：代码执行$6 \\div 3$，其计算公式为：\n",
    "\n",
    "   $$\n",
    "   \\text{division} = \\frac{\\text{num1}}{\\text{num2}} = \\frac{6}{3} = 2\n",
    "   $$\n",
    "\n",
    "   该计算得到的商为$2$。\n",
    "\n",
    "2. **结果显示**：代码使用格式化字符串将除法运算的结果输出为“`The division of 6 over 3 is 2`”。\n",
    "\n",
    "### 总结\n",
    "\n",
    "代码简单演示了基本的除法运算，并展示如何使用格式化字符串输出计算结果。此过程适用于基本的数值计算场景，尤其是在显示两个数的商时。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e5f9cfd9-fbd7-4efe-9e72-2086b8045f91",
   "metadata": {},
   "source": [
    "## 计算两个数字的除法并显示结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "57232dac-bada-452b-87b3-450fd3020742",
   "metadata": {},
   "outputs": [],
   "source": [
    "num1 = 6  # 定义第一个数字\n",
    "num2 = 3  # 定义第二个数字"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9630d233-8234-4e60-b177-01f237ecbcda",
   "metadata": {},
   "source": [
    "## 计算两个数字的除法结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1e3494ff-9393-4d8a-8531-f64bb1bbf7a3",
   "metadata": {},
   "outputs": [],
   "source": [
    "division = num1 / num2  # 计算num1除以num2的结果"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1fbe2685-cd10-4df6-b72e-333aa39b1804",
   "metadata": {},
   "source": [
    "## 显示计算结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b6e2cc58-b511-42ed-be74-43cde1fb02ef",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The division of 6 over 3 is 2.0\n"
     ]
    }
   ],
   "source": [
    "print('The division of {0} over {1} is {2}'.format(num1, num2, division))  # 输出除法结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "85a80909-2aac-49ed-bb7a-f8cc6b80ee7d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ecd322f4-f919-4be2-adc3-69d28ef25e69",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
